无法添加用户部门[ASP编写]

来源:百度知道 编辑:UC知道 时间:2024/06/01 09:52:31
无法添加用户部门。帮忙解决下,好吗?谢谢拉。
我本身就没有多少积分,所以就先悬赏10分吧,谢谢先! 比较急,望快点,谢谢。
<%
...
if departmentName<>"" then
if len(departmentName)>10 then
response.write "alert('增加失败!\n用户部门名称太长')"
response.end
else sql="select * from Dept where Dept='" & departmentName & "'"
set rs=conn.execute(sql)
if not rs.eof and not rs.bof then
response.write "alert('增加失败!')"
response.end
else
sql = "Insert Into Dept (Dept) Values( '"& departmentName & "')"
conn.Execute sql
set conn=nothing
response.write "<script>alert(' 增加成功!')</script>"
response.end
end if
end if
end if
%>
<%
set rs=nothing

<%
if departmentName<>"" then

if len(departmentName)>10 then
response.write "alert('增加失败!\n用户部门名称太长')"
response.end
else
sql="select * from Dept where Dept='" & departmentName & "'"
set rs=conn.execute(sql)
if rs.eof and rs.bof then
response.write "alert('增加失败!')"
response.end
else
sql = "Insert Into Dept (Dept) Values('"& departmentName & "')"
conn.Execute sql
set conn=nothing
response.write "<script>alert('增加成功!')</script>"
response.end
end if
end if

end if
%>

如果添加不成功 可以修改成 rs.addnew来添加记录。